
package com.lk.lkappearance.controller;

import com.lk.lkappearance.common.AbstractBaseController;
import com.lk.lkappearance.model.Device;
import com.lk.lkappearance.service.DeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/api/device")
public class DeviceController extends AbstractBaseController {
    @Autowired
    private DeviceService deviceService;

    /**
     *查看计量分析列表
     * @param device
     * @return
     */
    @RequestMapping(value = "/getList", method = RequestMethod.GET)
    public Map<String,Object> getList(@RequestBody Device device){
        log.info("查看计量分析列表");
        return deviceService.getList(device);
    }


    /**
     *根据主键查看计量分析列表
     * @param deviceId
     * @return
     */
    @RequestMapping(value="/getByPrimaryKey", method = RequestMethod.POST)
    public Map<String,Object> selectByPrimaryKey(@RequestParam String deviceId){
        log.info("查看计量分析列表");
        return deviceService.selectByPrimaryKey(deviceId);
    }

    /**
     *
     * @param device
     * @return
     */
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    public Map<String,Object> add(@RequestBody Device device){
        log.info("添加网络设备");
        return deviceService.add(device);
    }

    /**
     *
     * @param device
     * @return
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public Map<String,Object> update(@RequestBody Device device){
        log.info("修改网络设备");
        return deviceService.modify(device);
    }

    /**
     *
     * @param deviceId
     * @return
     */
    @RequestMapping(value = "/del", method = RequestMethod.POST)
    public Map<String,Object> delete(@RequestBody String deviceId){
        log.info("根据主键删除网络设备");
        return deviceService.delete(deviceId);
    }

    /**
     *
     * @param deviceList
     * @return
     */
    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
    public Map<String,Object> insertList(@RequestBody List<Device> deviceList){
        log.info("导入");
        return deviceService.insertListExcel(deviceList);
    }

    /**
     *导出计量分析列表
     * @param device
     * @return
     */
    @RequestMapping(value="/exportExcel", method = RequestMethod.GET)
    public Map<String,Object> getListExcel(@RequestBody Device device){
        log.info("导出计量分析列表");
        return deviceService.getListExcel(device);
    }


}
